//
//  AXMyGrzlVC.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/10/22.
//  Copyright © 2018年 tzhg. All rights reserved.
//

#import "AXMyGrzlVC.h"
#import "UIView+SDAutoLayout.h"
#import "ZXCategories.h"
#import "Header.h"
#import "UIViewController+HBD.h"
#import "AXMyGrzlMyImageviewCell.h"
#import "AXMyUserinfoTableViewCell.h"

@interface AXMyGrzlVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic ,strong) UITableView *tableView;
/** 假数据 */
@property (nonatomic, strong) NSArray<NSString *> *titles;




@end

@implementation AXMyGrzlVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
    [self setupNavigationItems];
    [self creatView];
    [self setlayout];

    /** 导航条白色 */
    self.hbd_barTintColor = [UIColor whiteColor];
    self.hbd_barShadowHidden = YES;
    
    
    
}

- (void)creatView {
    
    self.tableView = [[UITableView alloc]init];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.tableFooterView = [UIView new];
    //注册cell
    
    [self.tableView registerClass:[AXMyGrzlMyImageviewCell class] forCellReuseIdentifier:[AXMyGrzlMyImageviewCell reuseID]];
    ;
    [self.tableView registerClass:[AXMyUserinfoTableViewCell class] forCellReuseIdentifier:[AXMyUserinfoTableViewCell reuseID]];
    ;
    
    [self.view addSubview:self.tableView];
    
    
}

- (void)setlayout {
    
    self.tableView.sd_layout
    .leftSpaceToView(self.view, 0)
    .topSpaceToView(self.view, Hs)
    .widthIs(Wi)
    .heightIs(TableViewHeight);
    
    
 
}

#pragma mark -action




//自定义UIBarButtonItem
- (void)setupNavigationItems {
    
    /** 导航条左边的按钮 */
    //返回按钮
    UIButton *kfBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [kfBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    kfBtn.frame = CGRectMake(0, 0, 60, 30);
    [kfBtn addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:kfBtn];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    UILabel *titleLabel = [[UILabel alloc]init];
    titleLabel.textColor = [UIColor colorWithHex:0x29b566];
    titleLabel.text = @"个人资料";
    self.navigationItem.titleView = titleLabel;
    
    
    
}

#pragma mark - Action

- (void)backAction:(UIBarButtonItem *)item {
    [self.navigationController popViewControllerAnimated:YES];
}


#pragma mark - action



#pragma mark - tableViewDelegate & tableViewDatasorce



//几个分区
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    if(section == 0){
        return 1;
        
    }else if (section == 1){
        
        return 2;
    }
    return 2;
}

/** cell的高度 */

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        
        return 80;
    }
    if (indexPath.section == 1) {
        
        return 44;
    }
    
    
    return 44;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    if (indexPath.section == 0) {
        AXMyGrzlMyImageviewCell *cell = [tableView dequeueReusableCellWithIdentifier:[AXMyGrzlMyImageviewCell  reuseID] forIndexPath:indexPath];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        return cell;
    }
    
    /** 账户 昵称 、、、、*/
    if (indexPath.section == 1) {
        
        AXMyUserinfoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[AXMyUserinfoTableViewCell  reuseID] forIndexPath:indexPath];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        cell.leftLabel.text  = @[@"账户Id",@"昵称"][indexPath.row];
        cell.rightLabel.text  = @[@"1234567890",@"逍遥公子"][indexPath.row];
       
        return cell;
        
        
    }
   
    AXMyUserinfoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[AXMyUserinfoTableViewCell  reuseID] forIndexPath:indexPath];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
     cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.leftLabel.text  = @[@"我的二维码",@"性别"][indexPath.row];
    cell.rightLabel.text  = @[@"",@"男"][indexPath.row];
    return cell;
    
}





@end

